#include <bits/stdc++.h>
using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
using u128 = unsigned __int128;
using i128 = __int128;
using namespace std;

// 理解错了题目的意思
// 题目要求，能不能从两个数组中，恰好选出k/2个数，组合在一起，是1，2，3....k
void solve(vector<int>& a, vector<int>& b, int k) {
    int ia = 0, ib = 0;
    for (int i = 1; i < k / 2; i++) {
        while (ia < a.size() && a[ia] < i) ia++;
        while (ib < b.size() && b[ib] < i) ib++;

        if (ia == a.size() || ib == b.size()) {
            cout << "NO" << endl;
            return;
        }

        if (i == a[ia]) {
            ia++;
        } else if (i == b[ib]) {
            ib++;
        } else{
            cout << "NO" << endl;
            return;
        }
    }

    cout << "YES" << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int t;
    cin >> t;
    while (t--){
        // cin
        int m, n, k;
        cin >> n >> m >> k;
        vector<int> a(n);
        for (int i = 0; i < n; i++) cin >> a[i];
        vector<int> b(m);
        for (int i = 0; i < m; i++) cin >> b[i];
        solve(a, b, k);
    }

    return 0;
}